﻿using System;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Text.RegularExpressions;



namespace RtaInfoCMD.DataModel
{
	/// <summary>
	/// An object representing a PSG formatted RTA description.
	/// </summary>
	public class PsgDescription
	{
		private string _rtaNum;

		
		/// <summary>
		/// Initializes a new instance of the <see cref="PsgDescription"/> class.
		/// </summary>
		public PsgDescription()
		{
		}
				
		

		#region Properties
				
		/// <summary>Gets or sets the RTA number.</summary>
		/// <param name="value">The RTA number.</param>
		public string RtaNum
		{
			get { return this.GetRtaNum(this._rtaNum); }
			set { this._rtaNum = value; }
		}
		
		/// <summary>Gets or sets the RTA's issue source</summary>
		/// <param name="value">The RTA's issue source.</param>
		public string IssueSource	{ get; set; }
		
		/// <summary>Gets or sets the RTA's short description.</summary>
		/// <param name="value">The RTA's short description</param>
		public string ShortDesc     { get; set; }
		
		/// <summary>Gets or sets the RTA's issue description string.</summary>
		/// <param name="value">The RTA's issue description string.</param>
		public string IssueDesc     { get; set; }
		
		/// <summary>Gets or sets the PSG Response string.</summary>
		/// <param name="value">The PSG Response string</param>
		public string PsgResponse   { get; set; }
		
		/// <summary>Gets or sets the RTA's IssueTypes list.</summary>
		/// <param name="value">The RTA's IssueTypes list.</param>
		public Collection<string> IssueTypes    { get; set; }
		
		/// <summary>Gets or sets the RTA's affected assemblies list.</summary>
		/// <param name="value">The RTA's affected assemblies list.</param>
		public Collection<string> Assemblies    { get; set; }
		
		/// <summary>Gets or sets the RTA's affected sub-assemblies list.</summary>
		/// <param name="value">The RTA's affected sub-assemblies list.</param>
		public Collection<string> SubAssemblies { get; set; }
		
		/// <summary>Gets or sets the RTA's affected Work Orders list.</summary>
		/// <param name="value">The RTA's affected Work Orders list.</param>
		public Collection<string> WorkOrders    { get; set; }
		
		/// <summary>Gets or sets the RTA's affected ECN list</summary>
		/// <param name="value">The RTA's affected ECN list</param>
		public Collection<string> Ecns          { get; set; }
		
		#endregion
		
		
		/// <summary>
		/// Returns the shortended RTA number with leading 'R' and zeros removed.
		/// </summary>
		/// <param name="rtaNum">An RTA Number.</param>
		/// <remarks>If the input RTA number is already in short format, it will simply be returned as the result.</remarks>
		private string GetRtaNum(string rtaNum)
		{
			Regex pattern = new Regex(@"R0+?(?<rtaNum>[1-9]\d+)", RegexOptions.IgnoreCase);
			return pattern.Replace(rtaNum, "");
		}
		
	}





	//---------------------------------------------------------------------------------------------------


//	public enum SourceTypes
//	{
//		SM,
//		LM,
//		OM,
//		SP,
//		OP,
//		PLM
//	}


//	public class SourceType : IDictionary<string, string>
//	{
//		string[] types = { "Spring Manufacturing", "Livingston Manufacturing", "Other Manufacturing", "Spring Procurement", "Other Procurement", "Product Line Support" };
//		string[] codes = { "SM", "LM", "OM", "SP", "OP", "PLM" };



//		/// <summary>
//		/// Gets or sets the element with the specified key.
//		/// </summary>
//		/// <param name="type">The type.</param>
//		/// <returns></returns>
//		public Dictionary<string, string> this[SourceTypes type]
//		{
//			get
//			{
//				Dictionary<string, string> tmp = new Dictionary<string, string>();
//				tmp.Add(codes[(int)type], types[(int)type]);
//				return tmp;
//			}
//		}
//	}

}
